/**
 * @author: wq
 * @Date: 2017/5/10
 * @Time: 14:32
 * <p>
 * Description:
 *          ***
 */

import axios from 'axios';
import { API_NEW_VERSION } from '../api';

var qs = require('qs');

const ALI_PAY_RECHARGE = API_NEW_VERSION + 'alipay/recharge';
const UNION_PAY_RECHARGE = API_NEW_VERSION + 'unionpay/recharge';
const WECHAT_RECHARGE = API_NEW_VERSION + 'wechat/recharge';
const FUNDMEBACCTRFLOW_SERIALNO = API_NEW_VERSION + 'fundmebacctrflow/serialNo';

/**
 * 支付宝充值
 * @param params
 * @returns {AxiosPromise}
 */
export const aliPayRecharge = (userId, rechargeAmt) => {
  return axios.post(ALI_PAY_RECHARGE, qs.stringify({userId: userId, rechargeAmt: rechargeAmt}));
};

/**
 * new-支付宝充值
 * @param params
 * @returns {AxiosPromise}
 */
export const newAliPayRecharge = (userId, rechargeAmt, rechargeObjectType) => {
  return axios.post(API_NEW_VERSION + 'ali_pay/recharge', qs.stringify({
    recharge_object_type: rechargeObjectType,
    object_id: userId,
    recharge_amt: rechargeAmt
  }));
};

/**
 * 银联充值
 * @param userId
 * @param rechargeAmt
 * @returns {AxiosPromise}
 */
export const unionRecharge = (userId, rechargeAmt) => {
  return axios.post(UNION_PAY_RECHARGE, qs.stringify({userId: userId, rechargeAmt: rechargeAmt}));
};

/**
 * 微信充值
 * @param userId
 * @param rechargeAmt
 * @returns {AxiosPromise}
 */
export const weChatRecharge = (userId, rechargeAmt) => {
  return axios.post(WECHAT_RECHARGE, qs.stringify({userId: userId, rechargeAmt: rechargeAmt}));
};

/**
 * new-微信充值
 * @param userId
 * @param rechargeAmt
 * @returns {AxiosPromise}
 */
export const newWeChatRecharge = (userId, rechargeAmt, rechargeObjectType) => {
  return axios.post(API_NEW_VERSION + 'wechat_pay/recharge', qs.stringify({
    recharge_object_type: rechargeObjectType,
    object_id: userId,
    recharge_amt: rechargeAmt
  }));
};

/**
 * 微信充值定时请求是否充值成功
 * @param serialNo
 * @returns {AxiosPromise}
 * @constructor
 */
export const refreshWeChatRecharge = (serialNo) => {
  return axios.get(FUNDMEBACCTRFLOW_SERIALNO + '?serialNo=' + serialNo);
};
